/**
 * 
 */
package switchviz.gui;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JPanel;

import org.apache.log4j.Logger;

import switchviz.core.ResourceManager;
import switchviz.core.scenario.ScenarioPanel;
import switchviz.core.view.ViewPanel;
import switchviz.gui.component.StatusBar;
import switchviz.network.netswitch.SwitchPanel;
import switchviz.recording.RecordPanel;

/**
 * @author Thomas
 *
 */
public class MainPanel extends JPanel
{
	private static final long serialVersionUID = 1L;
	
	private static Logger logger  = Logger.getLogger(MainPanel.class);
	
	private MenuPanel _menuPanel 		= null;
	private CenterPanel _centerPanel 	= null;
	private StatusBar _statusBar		= null;
	
	/**
	 * This is the default constructor
	 */
	public MainPanel()
	{
		if (logger.isInfoEnabled()) { logger.info("Initialize ..."); }
		initialize();
	}
	
	public CenterPanel getCenterPanel()
	{
		if (_centerPanel == null)
			_centerPanel = new CenterPanel();
		
		return _centerPanel;
	}
	
	public StatusBar getStatusBar()
	{
		if (_statusBar == null)
			_statusBar = new StatusBar();
		
		return _statusBar;
	}
	
	private MenuPanel getMenuPanel()
	{
		if (_menuPanel == null)
		{
			_menuPanel = new MenuPanel(this);
			_menuPanel.add("Scenario", new JButton("Scenario", ResourceManager.getInstance().getImageIconScenario()), new ScenarioPanel());
			_menuPanel.add("View", new JButton("View", ResourceManager.getInstance().getImageIconView()), new ViewPanel());
			_menuPanel.add("Signals", new JButton("Signals", ResourceManager.getInstance().getImageIconSignal()), new ConfigurationPanel());
			_menuPanel.add("Switch", new JButton("Switch", ResourceManager.getInstance().getImageIconSwitch()), new SwitchPanel());
			_menuPanel.add("Records", new JButton("Records", ResourceManager.getInstance().getImageIconRecord()), new RecordPanel());
		}
		
		return _menuPanel;
	}
	
	private void initialize()
	{
		this.setLayout(new BorderLayout());
		add(getMenuPanel(), BorderLayout.NORTH);
		add(getCenterPanel(), BorderLayout.CENTER);	
		add(getStatusBar(), BorderLayout.SOUTH);
	}
	
}
